package com.c.ctgproject.wiget.dialog

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.c.ctgproject.base.BaseViewModel
import com.c.ctgproject.http.ApiMethods
import com.c.ctgproject.utils.awaitSync
import com.c.ctgproject.utils.handlerBody
import com.c.ctgproject.utils.launch
import com.c.ctgproject.utils.userToken
import okhttp3.MultipartBody
import okhttp3.RequestBody
import java.util.ArrayList

class ServicePayTypeViewModel :BaseViewModel(){
    private val mResult = MutableLiveData<String>()
    val result: LiveData<String> get() = mResult

    //收款方式 现金
    fun payMoney(suborderId:String){
        launch {
            mResult.value= ApiMethods.retrofit.serviceSaveCashPay(userToken, handlerBody(
                "suborderId" to suborderId
            )).awaitSync()
        }
    }


    fun payWeChat(file: ArrayList<MultipartBody.Part>){
        launch {
            mResult.value=ApiMethods.retrofit.serviceSaveWxPay(userToken,file).awaitSync()
        }
    }

    fun aliPayChat(body: RequestBody){
        launch {
            mResult.value=ApiMethods.retrofit.serviceSaveAliPay(userToken,body).awaitSync()
        }
    }


    fun bank(body: RequestBody){
        launch {
            mResult.value=ApiMethods.retrofit.serviceBank(userToken,body).awaitSync()
        }
    }

}